import React from 'react';
import Taro from '@tarojs/taro';
import { View } from '@tarojs/components';
import Card2 from '@/components/Card/Card2';
import { Button } from '@nutui/nutui-react-taro'
import styles from './style.scss';

export default function MedicalCard(props) {

  const { patient } = props;

  const btnText = !patient ? '添加就诊人' : '切换就诊人';

  const toPatient = () => {
    const url = !patient ? '/pages/addPatient/index' : '/pages/changePatient/index';
    Taro.navigateTo({ url });
  }
  
  return (
    <Card2 className={styles.card}>
      <View className={styles.body}>
        {props.children}
      </View>

      <View className={styles.action}>
        <Button
          color="#fff"
          type="default"
          size="small"
          style={{ color: 'var(--primary-color)', fontWeight: 700, letterSpacing: '1.5px' }}
          onClick={toPatient}
        >{btnText}</Button>
      </View>
    </Card2>
  );
}
